﻿using MK;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;

namespace AutoEditUI
{
    internal class AEWork
    {
        internal static void Init(MainWindow mMainWindow)
        {
            loadtxttocollection(mMainWindow, mMainWindow.ObservableFiveCode, MainWindow.gNowPath+"5code.txt");
        }

        public static void loadtxttocollection(MainWindow mMainWindow , ObservableCollection<string> observable, string filename)
        {
            StreamReader sRead = new StreamReader(filename/*.Replace(".tmp", ".txt")*/);
            string nowPC = sRead.ReadToEnd();
            sRead.Close();
            StringReader sr = new StringReader(nowPC);
            String line;
            List<string> mListmList = new List<string>();
            while ((line = sr.ReadLine()) != null)
            {
               if(!string.IsNullOrEmpty( line.Trim()))
                    observable.Add(line.Trim());
            }
        }

        public static void loadtxttocollection(MainWindow mMainWindow, List<string> observable, string filename)
        {
            if (observable.Count != 0) return;
            observable.Add("");
            StreamReader sRead = new StreamReader(filename/*.Replace(".tmp", ".txt")*/);
            string nowPC = sRead.ReadToEnd();
            sRead.Close();
            StringReader sr = new StringReader(nowPC);
            String line;
            List<string> mListmList = new List<string>();
            while ((line = sr.ReadLine()) != null)
            {
                if (!string.IsNullOrEmpty(line.Trim()))
                    observable.Add(line.Trim());
            }
        }
    }
}